<%--
  Created by IntelliJ IDEA.
  User: Gao
  Date: 2021/7/14
  Time: 16:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="header.jsp"%>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <%--${list}--%>
    <a class="btn btn-primary" href="/student_add.jsp">添加</a>
    <table class="table table-striped  table-bordered  table-hover  table-condensed">
        <tr>
            <td>ID</td>
            <td>名字</td>
            <td>年龄</td>
            <td>性别</td>
            <td>操作</td>
        </tr>
        <c:forEach items="${list}" var="student">
            <tr>
                <td>${student.id}</td>
                <td>${student.name}</td>
                <td>${student.age}</td>
                <td>${student.gender}</td>
                <td>
                    <a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="deleteById(${student.id})">删除</a>
                    <a class="btn btn-danger btn-xs" href="#">修改</a>
                </td>
            </tr>
        </c:forEach>
    </table>

    <script>
        var layer = layui.layer;
        // var num; js里面所有的变量定义都使用var
        // js里面字符串使用单引号和双引号都可以
        function deleteById(id) {
            layer.confirm(
                '您确认要删除么？',
                {icon:3},
                function() { // 当点击了确认按钮之后触发的方法
                    location.href = '/student/deleteById?id=' + id;
                }
            );
        }
    </script>
</body>
</html>
